package mx.netbrain.dao.impl;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;

import mx.netbrain.dao.PropertiesSignatureDao;
import mx.netbrain.util.HibernateUtil;

public class PropertiesSignatureDaoImpl implements PropertiesSignatureDao {

	private static final Logger logger = Logger
			.getLogger(PropertiesSignatureDaoImpl.class);

	@Override
	public void updateStatus(Integer status) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		try {
			session.beginTransaction();
			String sql = "update PropertiesSignature as propertiesSignature "
					+ "set propertiesSignature.status.id = :status ";
			Query query = session.createQuery(sql);
			query.setInteger("status", status);
			query.executeUpdate();
			session.beginTransaction().commit();
		} catch (Exception e) {
			logger.error("Update: " + e.getMessage());
			session.beginTransaction().rollback();
		}
	}

}
